package com.cxy.common.request;

import android.os.Bundle;

import androidx.annotation.NonNull;

import com.fy.baselibrary.utils.cache.SpfAgent;

/**
 * description </p>
 * Created by fangs on 2021/4/2 14:47.
 */
public class AppConstant {

    //缓存用户名 key
    public static String mobile = "mobile";//操作令牌 key
    public static String token = "token";//操作令牌 key
    public static String portrait_url = "portrait_url";//用户头像
    public static String userId = "userId";//用户id
    public static String chatId = "chatId";//用户聊天id
    public static String userName = "username";//用户名
    public static String roleId = "RoleId";//角色id
    public static String account = "account";//手机号
    public static String alarm = "alarmNum";//警号
    public static String deviceId = "deviceId";//设备id
    public static String pwdSecurity = "pwdSecurity";
    public static String mobileAccess = "mobileAccess";
    public static String lastLoginTime = "lastLoginTime";
    public static String userInfo = "userInfo";
    public static String shopBean = "ShopBean";
    public static String addGoods = "addGoods";



    /**AES加密，秘钥*/
    public static final String AESCODE = "VoSkEFQayXJT47VW";

    /**
     * 用户登录成功后，保存登录基本信息
     */
    public static void saveLoginUserInfo(@NonNull String userId, @NonNull String username, @NonNull String account, @NonNull String token,
                                         String deviceId, int pwdSecurity, boolean mobileAccess, String portrait_url){
        SpfAgent.init("")
                .saveString(AppConstant.userId, userId)
                .saveString(AppConstant.userName, username)
                .saveString(AppConstant.account, account)
                .saveString(AppConstant.token, token)
                .saveString(AppConstant.deviceId, deviceId)
                .saveString(AppConstant.portrait_url, portrait_url)
                .saveInt(AppConstant.pwdSecurity, pwdSecurity)
                .saveBoolean(AppConstant.mobileAccess, mobileAccess)
                .saveLong(AppConstant.lastLoginTime, System.currentTimeMillis())
                .commit(false);
    }

    /**
     * 获取登录用户信息
     * @return
     */
    public static Bundle getUserBundle() {
        Bundle bundle = new Bundle();
        bundle.putString(AppConstant.userId, SpfAgent.init("").getString(AppConstant.userId));
        bundle.putString(AppConstant.userName, SpfAgent.init("").getString(AppConstant.userName));
        bundle.putString(AppConstant.account, SpfAgent.init("").getString(AppConstant.account));
        bundle.putString(AppConstant.alarm, SpfAgent.init("").getString(AppConstant.alarm));
        bundle.putString(AppConstant.deviceId, SpfAgent.init("").getString(AppConstant.deviceId));
        bundle.putString(AppConstant.portrait_url, SpfAgent.init("").getString(AppConstant.portrait_url));

        return bundle;
    }

}
